package pl.perseus.action;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import pl.perseus.model.Rach;
import pl.perseus.model.User;
import pl.perseus.service.rach.IRachService;

public class GetAllRachsToTransferToAction extends BaseAction {

	@Autowired
	IRachService rachService;
	
	@Override
	public String execute() {
		
		result = new HashMap<String, Object>();
		User user = new User();
		user.setLogin(getCurrentUserLogin());
		List<Rach> list = rachService.getAllRachsToTransferTo(user);
		List<Map<String, String>> items = new LinkedList<Map<String, String>>();
		
		for(Rach r : list){
			Map<String, String> map = new HashMap<String, String>();
			map.put("id", r.getId().toString());
			map.put("name", r.getRach().toString());
			
			items.add(map);
		}
		
		
		result.put("identifier", "id");
		result.put("items", items);
		
		return SUCCESS;
		
	}

}
